home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / trubasic / rolldemos / TIPS < prev    next >
Text File  |  1994-08-02  |  3KB  |  92 lines

  1.  
  2. When creating a True BASIC UNIX graphics application, enclose the code
  3. in an error handler so that if in the unlikely case that an error occurs
  4. you can print out an informative message:
  5.  
  6.     when error in
  7.         call main_event_loop
  8.     use
  9.         set mode "text"
  10.         ! error message diagnostics
  11.         print extext$,extype,exline$
  12.     end when
  13.  
  14. Otherwise when an error occurs, the window will close and the program will
  15. end.  You can also use the routine SUB PIPE to print messages to stdout.
  16.  
  17. If the program returns to "graphics" mode, do not use the set mode "text"
  18. statement since this will alter the margin and max cursor settings.
  19. Use the PIPE subroutine instead.
  20.  
  21. -------------------------------------------------------------------------------
  22.  
  23. Remember that when the program ends the graphics window closes.  Use:
  24.  
  25.     GET KEY k
  26.  
  27. to wait for a key stroke at the end of your program.  If you want to respond
  28. to REFRESH events, use the statments:
  29.  
  30.     IF CHECK KEY INPUT THEN
  31.         ...
  32.     END IF
  33.     IF REFRESH(1)=1 THEN
  34.         ! your routine to refresh the screen
  35.         call refresh_screen
  36.     END IF
  37.  
  38. to check for input without blocking and to handle refresh/redraw events.
  39.  
  40. -------------------------------------------------------------------------------
  41.  
  42. A summary of commands can be found in "./cmdlist" with the corresponding
  43. man pages in "./manpp".  To display a manpage, either copy the files in
  44. "./manpp" to "usr/catman/local/cat1" and type:
  45.  
  46.     man <cmd>
  47.  
  48. or move to the "./manpp" directory and type:
  49.  
  50.         man -d <cmd.z>
  51.  
  52. where <cmd.z> is any of the files in the directory.
  53.  
  54. -------------------------------------------------------------------------------
  55.  
  56. Passing channel numbers to subroutines:
  57.  
  58. Channel numbers consist of the #<number> sequences in OPEN statements for
  59. windows and files.
  60.  
  61. Subroutines may have channel numbers as parameters.  Functions may not.
  62.  
  63. For example,
  64.  
  65.     SUB openfile (qu$, #1)        ! open a file
  66.         PRINT qu$;        ! prompt user
  67.         INPUT f$        ! name of file
  68.         CLOSE #1        ! in case #1 is open
  69.         OPEN #1: name f$    
  70.     END SUB
  71.  
  72.     CALL openfile("data file", #3)    ! invoke it
  73.  
  74. The file just opened becomes #3 in the calling program.  In this manner,
  75. you may use one subroutine to open different files.
  76.  
  77. WARNING:  it is possible to use a variable as the channel number but you
  78. may get the message "System error - margin <=0" or other related messages
  79. about the channel not being open.  It is suggested that the method in the
  80. example be used to avoid problems.
  81.  
  82. -------------------------------------------------------------------------------
  83.  
  84. When you create a stand-alone executable, you get everything from matrix
  85. operations to the Graphics Libaries.  For most programs the compile time
  86. is negligible and it is more practical to run programs from source.
  87.  
  88. Larger programs will be comparable in size with programs written in languages 
  89. such as C which optimize the code to a greater extent.
  90.        
  91. -------------------------------------------------------------------------------
  92.